from rest_framework import serializers

from user_info.models import Roles, UrlAddress, UserRoles, User


class RolesSerializer(serializers.ModelSerializer):
    name = serializers.CharField(required=True)

    class Meta:
        model = Roles
        fields = '__all__'


class UrlAddressSerializer(serializers.ModelSerializer):
    url_address = serializers.CharField(required=True)

    class Meta:
        model = UrlAddress
        fields = '__all__'


class UserSerializer(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = '__all__'


class UserRolesSerializer(serializers.ModelSerializer):
    role = RolesSerializer(read_only=True)
    user = UserSerializer(read_only=True)

    class Meta:
        model = UserRoles
        fields = '__all__'
